/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jtsmix.gui;

import org.jtsmix.editor.MixEditor;
import org.jtsmix.editor.MixEditorImpl;
import org.jtsmix.mixfile.GameType;
import org.jtsmix.mixfile.MixFileIndexEntry;
import org.jtsmix.mixfile.MixInfo;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author halecivo
 */
public class TSMixMainWindow extends javax.swing.JFrame {

    private MixEditor mixfile = new MixEditorImpl();
    private DefaultTableModel mixTableModel;
    private DefaultTableModel mixTableAdvancedModel;
    private GameType gameType = GameType.game_ts;

    class MixFileFilter implements FileFilter {

        @Override
        public boolean accept(File file) {
            if (file.getName().toLowerCase().endsWith("mix")) {
                return true;
            }
            return false;
        }
    }

    /**
     * Creates new form TSMixMainWindow
     */
    public TSMixMainWindow() {
        initComponents();
        String columns[] = {"Filename"};
        mixTableModel = new DefaultTableModel(columns, 0) {

            @Override
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        };
        String columns2[] = {"Filename", "ID", "Offset", "Size"};
        mixTableAdvancedModel = new DefaultTableModel(columns2, 0) {

            @Override
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }
        };
        jTable1.setModel(mixTableModel);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBGGameType = new javax.swing.ButtonGroup();
        jToolBar1 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        jButtonAddFile = new javax.swing.JButton();
        jButtonExportFile = new javax.swing.JButton();
        jButtonRemoveFile = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        jToggleButtonAdvancedView = new javax.swing.JToggleButton();
        jButtonMixInfo = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabelCmd = new javax.swing.JLabel();
        jTextFieldInputText = new javax.swing.JTextField();
        jButtonCmd = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenu1 = new javax.swing.JMenu();
        jRadioMenuTD = new javax.swing.JRadioButtonMenuItem();
        jRadioMenuRA = new javax.swing.JRadioButtonMenuItem();
        jRadioMenuTS = new javax.swing.JRadioButtonMenuItem();
        jMenuEdit = new javax.swing.JMenu();
        jMenuItemAddFile = new javax.swing.JMenuItem();
        jMenuItemExportFile = new javax.swing.JMenuItem();
        jMenuItemExportAll = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItemRemoveFile = new javax.swing.JMenuItem();
        jMenuView = new javax.swing.JMenu();
        jCheckBoxMenuItemAdvancedView = new javax.swing.JCheckBoxMenuItem();
        jMenuHelp = new javax.swing.JMenu();
        jMenuItemAbout = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("jTSMix");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(400, 300));

        jToolBar1.setRollover(true);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/folder_go.png"))); // NOI18N
        jButton1.setToolTipText("Open Mix Archive");
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton1);

        jButtonAddFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/add.png"))); // NOI18N
        jButtonAddFile.setToolTipText("Add File...");
        jButtonAddFile.setEnabled(false);
        jButtonAddFile.setFocusable(false);
        jButtonAddFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonAddFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonAddFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddFileActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonAddFile);

        jButtonExportFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/disk.png"))); // NOI18N
        jButtonExportFile.setToolTipText("Export Selected File(s)");
        jButtonExportFile.setEnabled(false);
        jButtonExportFile.setFocusable(false);
        jButtonExportFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonExportFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonExportFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExportFileActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonExportFile);

        jButtonRemoveFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/delete.png"))); // NOI18N
        jButtonRemoveFile.setToolTipText("Delete Selected File(s)");
        jButtonRemoveFile.setEnabled(false);
        jButtonRemoveFile.setFocusable(false);
        jButtonRemoveFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonRemoveFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonRemoveFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRemoveFileActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonRemoveFile);
        jToolBar1.add(jSeparator1);

        jToggleButtonAdvancedView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/table_lightning.png"))); // NOI18N
        jToggleButtonAdvancedView.setToolTipText("Advanced View");
        jToggleButtonAdvancedView.setFocusable(false);
        jToggleButtonAdvancedView.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jToggleButtonAdvancedView.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToggleButtonAdvancedView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonAdvancedViewActionPerformed(evt);
            }
        });
        jToolBar1.add(jToggleButtonAdvancedView);

        jButtonMixInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/information.png"))); // NOI18N
        jButtonMixInfo.setEnabled(false);
        jButtonMixInfo.setFocusable(false);
        jButtonMixInfo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonMixInfo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonMixInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMixInfoActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonMixInfo);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START);

        jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS));

        jLabelCmd.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabelCmd.setText("Find: ");
        jLabelCmd.setEnabled(false);
        jPanel1.add(jLabelCmd);

        jTextFieldInputText.setEnabled(false);
        jTextFieldInputText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldInputTextKeyReleased(evt);
            }
        });
        jPanel1.add(jTextFieldInputText);

        jButtonCmd.setText("ok");
        jButtonCmd.setEnabled(false);
        jButtonCmd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCmdActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonCmd);

        getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{
                        {null, null, null, null},
                        {null, null, null, null},
                        {null, null, null, null},
                        {null, null, null, null}
                },
                new String[]{
                        "Title 1", "Title 2", "Title 3", "Title 4"
                }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTable1);

        getContentPane().add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jMenuFile.setText("File");
        jMenuFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuFileActionPerformed(evt);
            }
        });

        jMenuItem1.setText("New...");
        jMenuItem1.setEnabled(false);
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItem1);

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/folder_go.png"))); // NOI18N
        jMenuItem2.setText("Open");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItem2);
        jMenuFile.add(jSeparator3);

        jMenu1.setText("Game type");

        jBGGameType.add(jRadioMenuTD);
        jRadioMenuTD.setMnemonic('1');
        jRadioMenuTD.setText("Tiberian Dawn");
        jRadioMenuTD.setToolTipText("");
        jRadioMenuTD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioMenuTDActionPerformed(evt);
            }
        });
        jMenu1.add(jRadioMenuTD);

        jBGGameType.add(jRadioMenuRA);
        jRadioMenuRA.setMnemonic('2');
        jRadioMenuRA.setText("Red Alert");
        jRadioMenuRA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioMenuRAActionPerformed(evt);
            }
        });
        jMenu1.add(jRadioMenuRA);

        jBGGameType.add(jRadioMenuTS);
        jRadioMenuTS.setSelected(true);
        jRadioMenuTS.setText("Tiberian Sun");
        jRadioMenuTS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioMenuTSActionPerformed(evt);
            }
        });
        jMenu1.add(jRadioMenuTS);

        jMenuFile.add(jMenu1);

        jMenuBar1.add(jMenuFile);

        jMenuEdit.setText("Edit");
        jMenuEdit.setEnabled(false);

        jMenuItemAddFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAddFile.setText("Add File...");
        jMenuItemAddFile.setActionCommand("jMenuItemAddFile");
        jMenuItemAddFile.setEnabled(false);
        jMenuItemAddFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAddFileActionPerformed(evt);
            }
        });
        jMenuEdit.add(jMenuItemAddFile);

        jMenuItemExportFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemExportFile.setText("Export selected File");
        jMenuItemExportFile.setEnabled(false);
        jMenuItemExportFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemExportFileActionPerformed(evt);
            }
        });
        jMenuEdit.add(jMenuItemExportFile);

        jMenuItemExportAll.setText("Export all");
        jMenuItemExportAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemExportAllActionPerformed(evt);
            }
        });
        jMenuEdit.add(jMenuItemExportAll);
        jMenuEdit.add(jSeparator2);

        jMenuItemRemoveFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, java.awt.event.InputEvent.SHIFT_MASK));
        jMenuItemRemoveFile.setText("Remove selected File");
        jMenuItemRemoveFile.setEnabled(false);
        jMenuEdit.add(jMenuItemRemoveFile);

        jMenuBar1.add(jMenuEdit);

        jMenuView.setText("View");
        jMenuView.setActionCommand("jMenuView");

        jCheckBoxMenuItemAdvancedView.setText("Advanced View");
        jCheckBoxMenuItemAdvancedView.setActionCommand("jCheckBoxMenuItemAdvancedView");
        jCheckBoxMenuItemAdvancedView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemAdvancedViewActionPerformed(evt);
            }
        });
        jMenuView.add(jCheckBoxMenuItemAdvancedView);

        jMenuBar1.add(jMenuView);
        jMenuView.getAccessibleContext().setAccessibleName("jMenuView");

        jMenuHelp.setText("Help");

        jMenuItemAbout.setText("About...");
        jMenuItemAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAboutActionPerformed(evt);
            }
        });
        jMenuHelp.add(jMenuItemAbout);

        jMenuBar1.add(jMenuHelp);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuFileActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuFileActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // Open...
        final JFileChooser fc = new JFileChooser();

        //In response to a button click:
        //fc.setFileFilter(new MixFileFilter());
        if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
            try {
                File mixToOpen = fc.getSelectedFile();
                mixfile.open(mixToOpen.toString(), gameType);
                this.setTitle("jTSMix: " + mixToOpen.getName());
                mixTableModel.setRowCount(0);
                mixTableAdvancedModel.setRowCount(0);

                for (String s : mixfile.getFileNameList()) {
                    String columns[] = {s};
                    mixTableModel.addRow(columns);
                }

                int i = 0;
                for (MixFileIndexEntry file : mixfile.getFileList()) {
                    String columns[] = {(String) mixTableModel.getValueAt(i++, 0), Long.toHexString(file.getCrcId()), Long.toString(file.getOffset()), Long.toString(file.getSize())};
                    mixTableAdvancedModel.addRow(columns);
                }
            } catch (FileNotFoundException ex) {
                Logger.getLogger(TSMixMainWindow.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(TSMixMainWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
            jMenuEdit.setEnabled(true);
            jMenuItemAddFile.setEnabled(true);
            jButtonAddFile.setEnabled(true);
            jButtonMixInfo.setEnabled(true);
            jLabelCmd.setEnabled(true);
            jTextFieldInputText.setEnabled(true);
            jButtonCmd.setEnabled(true);
        }

    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        jMenuItem2ActionPerformed(evt);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButtonCmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCmdActionPerformed
        // TODO add your handling code here:
        String textInput = jTextFieldInputText.getText();
        for (int i = 0; i < mixTableModel.getRowCount(); i++) {
            if (mixTableModel.getValueAt(i, 0).equals(textInput)) {
                jTable1.setRowSelectionInterval(i, i);
                jTable1MouseClicked(null);
                return;
            }
        }
        JOptionPane.showMessageDialog(this,
                "Archive does not contain file '" + textInput + "'.",
                "File search",
                JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jButtonCmdActionPerformed

    private void jToggleButtonAdvancedViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonAdvancedViewActionPerformed
        int s = jTable1.getSelectedRow();
        if (jToggleButtonAdvancedView.isSelected()) {
            jToggleButtonAdvancedView.setSelected(true);
            jCheckBoxMenuItemAdvancedView.setSelected(true);
            jTable1.setModel(mixTableAdvancedModel);
        } else {
            jToggleButtonAdvancedView.setSelected(false);
            jCheckBoxMenuItemAdvancedView.setSelected(false);
            jTable1.setModel(mixTableModel);
        }
        if (s >= 0) {
            jTable1.setRowSelectionInterval(s, s);
        }
    }//GEN-LAST:event_jToggleButtonAdvancedViewActionPerformed

    private void jButtonAddFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddFileActionPerformed
        final JFileChooser fc = new JFileChooser();
        if (jTable1.getSelectedRow() >= 0) {
            fc.setSelectedFile(new File((String) mixTableModel.getValueAt(jTable1.getSelectedRow(), 0)));
        }
        if (fc.showOpenDialog(this) == fc.APPROVE_OPTION) {
            try {
                mixfile.addFile(fc.getSelectedFile().toString());
            } catch (FileNotFoundException ex) {
                Logger.getLogger(TSMixMainWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jButtonAddFileActionPerformed

    private void jButtonExportFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportFileActionPerformed
        final JFileChooser fc = new JFileChooser();
        fc.setSelectedFile(new File((String) mixTableModel.getValueAt(jTable1.getSelectedRow(), 0)));
        if (fc.showSaveDialog(this) == fc.APPROVE_OPTION) {
            mixfile.extract((String) mixTableModel.getValueAt(jTable1.getSelectedRow(), 0), fc.getSelectedFile().toString());
        }
    }//GEN-LAST:event_jButtonExportFileActionPerformed

    private void jButtonRemoveFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveFileActionPerformed
        mixfile.removeFile((String) mixTableModel.getValueAt(jTable1.getSelectedRow(), 0));
    }//GEN-LAST:event_jButtonRemoveFileActionPerformed

    private void jMenuItemAddFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAddFileActionPerformed
        jButtonAddFileActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemAddFileActionPerformed

    private void jCheckBoxMenuItemAdvancedViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemAdvancedViewActionPerformed
        // TODO add your handling code here:
        jToggleButtonAdvancedView.setSelected(jCheckBoxMenuItemAdvancedView.isSelected());
        jToggleButtonAdvancedViewActionPerformed(evt);
    }//GEN-LAST:event_jCheckBoxMenuItemAdvancedViewActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        boolean enabled = false;
        if (jTable1.getSelectedRow() >= 0) {
            enabled = true;
        }
        jButtonExportFile.setEnabled(enabled);
        jButtonRemoveFile.setEnabled(enabled);
        jMenuItemExportFile.setEnabled(enabled);
        jMenuItemRemoveFile.setEnabled(enabled);
    }//GEN-LAST:event_jTable1MouseClicked

    private void jButtonMixInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMixInfoActionPerformed
        MixInfo mixinfo = mixfile.getMixInfo();
        JOptionPane.showMessageDialog(this,
                "File: '" + mixinfo.getFileName() + "'\n"
                        + "Number of files: " + mixinfo.getNumFiles() + "\n"
                        + "Content size: " + mixinfo.getBodySize() + " B",
                "Mix archive info",
                JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jButtonMixInfoActionPerformed

    private void jTextFieldInputTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldInputTextKeyReleased
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            jButtonCmdActionPerformed(null);
        }
    }//GEN-LAST:event_jTextFieldInputTextKeyReleased

    private void jMenuItemAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAboutActionPerformed
        JOptionPane.showMessageDialog(this,
                "jTSMix v0.1\n"
                        + "Ivo Háleček \n"
                        + "http://jtsmix.googlecode.com",
                "About jTSMix",
                JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jMenuItemAboutActionPerformed

    private void jMenuItemExportAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExportAllActionPerformed
        final JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        if (fc.showSaveDialog(this) == fc.APPROVE_OPTION) {
            mixfile.extractAll(fc.getSelectedFile().toString());
        }
    }//GEN-LAST:event_jMenuItemExportAllActionPerformed

    private void jMenuItemExportFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExportFileActionPerformed
        jButtonExportFileActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemExportFileActionPerformed

    private void jRadioMenuTDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioMenuTDActionPerformed
        gameType = GameType.game_td;
    }//GEN-LAST:event_jRadioMenuTDActionPerformed

    private void jRadioMenuTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioMenuTSActionPerformed
        gameType = GameType.game_ts;
    }//GEN-LAST:event_jRadioMenuTSActionPerformed

    private void jRadioMenuRAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioMenuRAActionPerformed
        gameType = GameType.game_ra;
    }//GEN-LAST:event_jRadioMenuRAActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TSMixMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TSMixMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TSMixMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TSMixMainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TSMixMainWindow().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup jBGGameType;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonAddFile;
    private javax.swing.JButton jButtonCmd;
    private javax.swing.JButton jButtonExportFile;
    private javax.swing.JButton jButtonMixInfo;
    private javax.swing.JButton jButtonRemoveFile;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemAdvancedView;
    private javax.swing.JLabel jLabelCmd;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMenuEdit;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenu jMenuHelp;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItemAbout;
    private javax.swing.JMenuItem jMenuItemAddFile;
    private javax.swing.JMenuItem jMenuItemExportAll;
    private javax.swing.JMenuItem jMenuItemExportFile;
    private javax.swing.JMenuItem jMenuItemRemoveFile;
    private javax.swing.JMenu jMenuView;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButtonMenuItem jRadioMenuRA;
    private javax.swing.JRadioButtonMenuItem jRadioMenuTD;
    private javax.swing.JRadioButtonMenuItem jRadioMenuTS;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextFieldInputText;
    private javax.swing.JToggleButton jToggleButtonAdvancedView;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
